mui.init();
//获取本地信息
var my_phone = localStorage.getItem("my_phone");
var user_id = localStorage.getItem("user_id");
var preDeposit, Grade, status; //公共变量
window.onload = function() {
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		preDeposit = self.preDeposit;
		$("#advance_payment_num").text(preDeposit);
		silverInfo()
		
	});
}
// api/user/silverInfo
function silverInfo(){
	mui.ajax(user_url +'/api/user/silverInfo',{
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success:function(data){
			console.log(JSON.stringify(data))
			if(data.success == true) {
				var silver_treasure = data.resp.silver_treasure
				var convert_silver = data.resp.convert_silver
				var consume_silver = data.resp.consume_silver
				$('#availableIntegr_num').text(silver_treasure);
				$('#lock_num').text(data.resp.lock_silver_treasure);
				$('#stockIntegr_num').text(consume_silver);
				$('#preDeposit_num').text(convert_silver);
				
			}
		}
	})
}
////返回user页面
$(document).on('tap', '.go_user', function() {
	mui.back();
})
//充值
//document.getElementById("imprest_recharge").addEventListener("tap", function() {
////	if(status == 2) {
////		mui.toast('账户已被限制，请联系平台。');
////		return;
////	}
//	mui.openWindow({
//		url: '../my/cash_recha.html',
//		createNew: true,
//	});
//});
//明细
document.getElementById("detail_page").addEventListener("tap", function() {
	//cash_record.html
	mui.openWindow({
		url: '../my/yinbao_record.html',
		createNew: true,
	});
});
//提现
//document.getElementById("put_forward").addEventListener("tap", function() {
//	mui.openWindow({
//		url: "../my/cash_advance.html",
//		id: "cash_advance"
//	});
//});

//调用userinfo接口判断是否是商家
//function userinfo() {
//	mui.ajax(user_url + '/api/userinfo', { //查询用户信息接口
//		data: {
//			"phone": my_phone,
//			"sign": "string",
//			"user_id": user_id
//		},
//		dataType: 'json', //服务器返回json格式数据
//		type: 'post', //HTTP请求类型
//		timeout: 10000, //超时时间设置为10秒；
//		headers: {
//			'Content-Type': 'application/json'
//		},
//		success: function(data) {
//			if(data.code == 10000) {
//				Grade = data.resp.level; //个人等级
//				status = data.resp.status; //账户状态
//			}
//		},
//		error: function(xhr, type, errorThrown) { //异常处理；
//			console.log(type);
//		}
//	});
//}